<template>
  <div>
    <h3>结算页面</h3>
    <div>
        <div v-if="showAddress.id">
            <span>收件人{{ showAddress.name }}</span>
            <span>电话{{ showAddress.tel }}</span>
            <span>地址{{ showAddress.province+""+showAddress.city+""+showAddress.county+""+showAddress.addressDetail }}</span>
            <button @click="gotoAdd">选择其他收货地址</button>
        </div>
        <div v-else>
            <button @click="gotoAdd">新增地址</button>
        </div>
    </div>
    <van-card
      v-for="item in shoppingcarList.filter((info) => info.checked)"
      :key="item.id"
      :num="item.buynum"
      :price="item.goodsprice / 100"
      :title="item.goodsname"
      :thumb="item.img"
    >
    </van-card>
  </div>
</template>

<script>
import { changeNav } from "@/mixins/changenav";
import { mapState,mapGetters } from "vuex";
export default {
  mixins: [changeNav],
  methods:{
    gotoAdd(){
        this.$router.push("/address");
    }
  },
  computed: {
    ...mapState("shoppingStore", {
      shoppingcarList: "list",
    }),
    ...mapState("myaddressStore", {
      addressList: "list",
    }),
    ...mapGetters("myaddressStore",["defaultChooseId"]),
    showAddress(){
        let  info  = {};
        if(this.addressList.length){
            info = this.addressList.filter(item=>item.id==this.defaultChooseId)[0]
        }
        return info;
    }
  },
};
</script>

<style></style>
